namespace Resharper.Abstractions.CodeDom.Statements.IfStatements
{
  using JetBrains.Annotations;
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using Resharper.Abstractions.CodeDom.Expressions;
  using Resharper.Abstractions.CodeDom.Statements.ForStatements;

  /// <summary>Defines the <see cref="ForStatement"/> class.</summary>
  public class IfStatement : Statement
  {
    #region Constructors and Destructors

    /// <summary>Initializes a new instance of the <see cref="ForStatement"/> class.</summary>
    /// <param name="statement">The expression.</param>
    internal IfStatement([NotNull] IIfStatement statement) : base(statement)
    {
    }

    #endregion

    #region Properties

    /// <summary>
    /// Gets the expression.
    /// </summary>
    [CanBeNull]
    public Expression Condition
    {
      get
      {
        var condition = this.InternalIfStatement.Condition;

        return condition != null ? ExpressionFactory.GetExpression(condition) : null;
      }
    }

    /// <summary>
    /// Gets the internal for statement.
    /// </summary>
    [NotNull]
    internal IIfStatement InternalIfStatement
    {
      get
      {
        return (IIfStatement)this.InternalStatement;
      }
    }

    #endregion
  }
}